Page({
    data: {
        name:"管理员名字",
        showLoadingState:false,
        //头像
        p0:"https://pic.imgdb.cn/item/62d68d1ef54cd3f93723f49d.png",
        userProfile:"https://pic1.imgdb.cn/item/63650a4116f2c2beb1e3a16a.png",
        //五个接口
        p1:"https://pic.imgdb.cn/item/62dfc6cbf54cd3f93730a743.png",
        p2:"https://pic.imgdb.cn/item/62dfc6cbf54cd3f93730a769.png",
        p3:"https://pic.imgdb.cn/item/62dfc6cbf54cd3f93730a775.png",
        p4:"https://pic1.imgdb.cn/item/636a30d116f2c2beb1251b2e.png",
        p9:"https://pic1.imgdb.cn/item/636a462116f2c2beb1469694.png",
        text:"关于Match",
        text2:"退出登录",
    }, 
    onLoad:function(e){
        var userprofile = getApp().globalData.userInfo.userProfile;
        this.setData({
            'userProfile':userprofile,
            "name":getApp().globalData.userInfo.userName,
        })
    },
    onShow(){
        var userprofile = getApp().globalData.userInfo.userProfile;
        this.setData({
            'userProfile':userprofile,
        })
    },
    
    //修改用户头像
    onChangeUserProfile:function(e){
        wx.showModal({
          title:"暂不支持更改头像，敬请期待",
        })
        // var that = this;
        // var picUrl = e.detail.avatarUrl;
        // var studentid = getApp().globalData.userInfo.studentId;
        
        // wx.uploadFile({
        //     filePath: 'picUrl',
        //     name: 'picture',
        //     url: 'https://api.superbed.cn/upload',
        //     success(res){
        //         console.log(res)
        //     },
        //     fail(res){
        //         console.log(res)
        //     }
        //   })


        
        // that.onShowLoading();
        // wx.request({
        //     url: getApp().globalData.serverUrl,
        //     method:"GET",
        //     timeout:1500,
        //     data:{
        //       //各种数据的传送
        //       operation:"CHANGE_PROFILE",
        //       studentId:studentid,
        //       userProfile:picUrl,
        //     },
        //     success(res){
        //       if(res.data == false){
        //           that.onHideLoading();
        //           wx.showModal({
        //               showCancel:false,
        //               title:"请求失败,请重试",
        //           });
        //       }
        //       else{
        //           //成功获取到信息后的操作
        //         that.setData({
        //             "userProfile":picUrl,
        //         });
        //         getApp().globalData.userInfo.userProfile = picUrl;
        //         that.onHideLoading();
        //       }
        //     },
        //     fail(res){
        //         that.onHideLoading();
        //       wx.showModal({
        //           showCancel:false,
        //           title:"请求超时,请重试",
        //       });
        //     },
        // });
        
    },
    //跳转接口
    toPage_basic_page:function(e){
        wx.navigateTo({
          url: '/pages/basic-page/basic-page',
        })
    },
    toPage_pkvalue_page:function(e){
        wx.navigateTo({
          url: '/pages/pkvalue-page/pkvalue-page',
        })
    },
    toPage_personal_rooms_page:function(e){
        wx.navigateTo({
          url: '/pages/personal-rooms-page/personal-rooms-page',
        })
    },
    toPage_about_us_page:function(e){
        wx.navigateTo({
          url: '/pages/about-us-page-user/about-us-page-user',
        })
    },
    toPage_show_orders_page:function(e){

        wx.redirectTo({
          url: '/pages/show-orders-page/show-orders-page',
        })
    },
    onLogout:function(e){
        var that = this;
        wx.showModal({
          title:"您确定要注销吗？",
          success(res){
              if(res.confirm){
                getApp().globalData.isLogin = false;
                    wx.redirectTo({
                        url: '/pages/main-page/main-page',
                      });


              }
          }
        })
    },
    onShowLoading:function(e){
        var that = this;
        wx.showLoading({
          title: '加载中',
          mask:true,
          success(res){
              that.setData({
                  "showLoadingState":true,
              })
          }
        })
        setTimeout(that.onHideLoading,1800)
    },
    onHideLoading:function(e){
        var that = this;
        if(that.data.showLoadingState == true){
            wx.hideLoading();
            that.setData({ 
                "showLoadingState":false,
            })
        }
    },
})